from pydantic import BaseModel, Field
from datetime import datetime
from typing import Optional

class RolePermissionBase(BaseModel):
    # 必填字段
    role_id: int = Field(..., description="角色ID")
    permission_id: int = Field(..., description="权限ID")

class RolePermissionCreate(RolePermissionBase):
    """创建角色权限关联时使用的模型"""
    
    class Config:
        from_attributes = True

class RolePermissionUpdate(BaseModel):
    """更新角色权限关联时使用的模型"""
    role_id: Optional[int] = None
    permission_id: Optional[int] = None
    
    class Config:
        from_attributes = True

class RolePermission(RolePermissionBase):
    id: int
    create_time: Optional[datetime] = Field(None, description="创建时间")
    
    class Config:
        from_attributes = True